<HTML>
<BODY>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->

<B><A HREF="LSEEK.html">LSEEK(2)</A></B>		  FreeBSD System Calls Manual		      <B><A HREF="LSEEK.html">LSEEK(2)</A></B>


</PRE>
<H2>NAME</H2><PRE>
     <B>lseek</B> - reposition read/write file offset


</PRE>
<H2>SYNOPSIS</H2><PRE>
     <B>#include</B> <B>&lt;unistd.h&gt;</B>

     <I>off</I><B>_</B><I>t</I>
     <B>lseek</B>(<I>int</I> <I>fildes</I>, <I>off</I><B>_</B><I>t</I> <I>offset</I>, <I>int</I> <I>whence</I>)


</PRE>
<H2>DESCRIPTION</H2><PRE>
     The <B>lseek</B>() function repositions the offset of the file descriptor <I>fildes</I>
     to the argument <I>offset</I> according to the directive <I>whence.</I> The argument
     <I>fildes</I> must be an open file descriptor.  <B>Lseek</B>() repositions the file po-
     sition pointer associated with the file descriptor <I>fildes</I> as follows:

	   If <I>whence</I> is SEEK_SET, the offset is set to <I>offset</I> bytes.

	   If <I>whence</I> is SEEK_CUR, the offset is set to its current location
	   plus <I>offset</I> bytes.

	   If <I>whence</I> is SEEK_END, the offset is set to the size of the file
	   plus <I>offset</I> bytes.

     The <B>lseek</B>() function allows the file offset to be set beyond the end of
     the existing end-of-file of the file. If data is later written at this
     point, subsequent reads of the data in the gap return bytes of zeros (un-
     til data is actually written into the gap).

     Some devices are incapable of seeking.  The value of the pointer associ-
     ated with such a device is undefined.


</PRE>
<H2>RETURN VALUES</H2><PRE>
     Upon successful completion, <B>lseek</B>() returns the resulting offset location
     as measured in bytes from the beginning of the file.  Otherwise, a value
     of -1 is returned and <I>errno</I> is set to indicate the error.


</PRE>
<H2>ERRORS</H2><PRE>
     <B>Lseek</B>() will fail and the file position pointer will remain unchanged if:

     [EBADF]   <I>Fildes</I> is not an open file descriptor.

     [ESPIPE]  <I>Fildes</I> is associated with a pipe, socket, or FIFO.

     [EINVAL]  <I>Whence</I> is not a proper value.


</PRE>
<H2>SEE ALSO</H2><PRE>
     <B><A HREF="dup.html">dup(2)</A></B>,  <B><A HREF="open.html">open(2)</A></B>


</PRE>
<H2>BUGS</H2><PRE>
     This document's use of <I>whence</I> is incorrect English, but is maintained for
     historical reasons.


</PRE>
<H2>STANDARDS</H2><PRE>
     The <B>lseek</B>() function call is expected to conform to IEEE Std1003.1-1990
     (``POSIX'').


</PRE>
<H2>HISTORY</H2><PRE>
     A <B>lseek</B>() function call appeared in Version 7 AT&amp;T UNIX.

4th Berkeley Distribution	April 19, 1994				     1
</PRE>
<HR>
<ADDRESS>
Man(1) output converted with
<a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
</ADDRESS>
</BODY>
</HTML>
